1. Field of the Invention
The present invention relates to a coding apparatus and a coding method of executing high-efficient coding to compress image data.
2. Description of the Related Art
In storing image signals picked up by a solid state image pickup apparatus, represented by a CCD (Charge Coupled Device), as digital data into a memory device such as a memory card or magnetic disk, because of a vast amount of data involved, data of the acquired image signals should be subjected to some sort of compression to store many frame images within a limited storage capacity. For instance, a digital electronic still camera stores picked-up images as digital data into a data storage medium, such as a memory card or magnetic disk, in place of silver salt film, so that the number of images recordable on a single memory card or magnetic disk drive is specified or restricted, and recording of the restricted number of images should be assured. Further, it is necessary that the time required for data recording/reproduction be short and constant.
As an image data compressing method, which satisfies these conditions, there is a well-known coding method which is a combination of the orthogonal transform coding and entropy coding.
A typical method of this type is what is studied in the international standardization of the still image.
This system will be briefly described below. To begin with, for example, a frame of image data is divided into blocks of a predetermined size, and each block of image data is subjected to two dimensional DCT (Discrete Cosine Transform) as orthogonal transform. Then, linear quantization according to each frequency component is executed. This quantized value undergoes Huffman coding as entropy coding. At this time, with regard to the DC component of this block, the differential value between the DC component and that of a nearby block is subjected to Huffman coding. An AC component undergoes so-called zigzag scanning from a low frequency component to a high frequency component and Huffman coding is executed on the basis of the number of consecutive components which are invalid (values being zero) and the value of the subsequent valid component. The above is the basic portion of this system.
With this basic portion alone, the amount of codes does not become constant for each image due to the use of the Huffman coding as entropy coding.
The following system has therefore been proposed as a method of controlling the amount of codes. First, the processing of the basic portion is executed, and the total amount of codes generated on the entire screen is acquired at the same time. From this total amount of codes and the desired or target amount of codes, the optimal quantization width to make the amount of codes approach the target amount of codes to the DCT coefficient will be predicted. Using this quantization width, the process following the quantization of the basic portion is repeated. Then, from the total amount of codes generated this time, the total amount of codes generated previously and the target amount of codes, the optimal quantization width to make the amount of codes approach the target amount of codes is predicted again. When the predicted quantization width coincides with the previous quantization width and the total amount of codes presently generated is less than the target amount of codes, the process is terminated and codes are output. If otherwise, the above described process will be repeated using a new quantization width.
The necessary quantization width is obtained by multiplying a basic form of the standard quantization characteristic by a quantization width coefficient .alpha.. More specifically, first, the aforementioned quantization of the basic portion is conducted with a quantization width acquired using a standard quantization width coefficient .alpha., the result is subjected to the entropy coding, the resulting data of the total amount of codes is compared with the target total amount of codes preset as a limit, the final coding process is executed using the quantization width when the former amount reaches the latter, the optimal quantization width coefficient .alpha. to make the amount of codes approach the target total amount of codes is acquired from the total amount of codes generated and the target amount, using the Newton-Raphson iteration method, for example, when the amount of codes is not within the target quantity, the basic form of the standard quantization characteristic is compensated using this obtained quantization width coefficient to thereby acquire more optimized quantization width, and the final processing is performed using this quantization width. In this manner, the characteristic of quantization is altered.
The above operation will be specifically explained below referring to FIG. 6. To begin with, as shown in (a) in this diagram, one frame of image data (one frame of image specified by the international standardization proposal is 720.times.576 pixels) is divided into blocks of a predetermined size (e.g., blocks A, B, C, . . . consists of 8.times.8 pixels), the two dimensional DCT is executed as orthogonal transform for each block, as shown in (b), and the resulting data is sequentially stored on an 8.times.8 matrix memory. The image data as viewed from the two-dimensional point has a spatial frequency that is the frequency data based on the distribution of density data.
Through the DCT, therefore, the image data is transformed into a DC component DC and an AC component AC, and data representing the DC component DC is stored on the 8.times.8 matrix memory at the origin (0, 0), data indicating the maximum frequency value of the AC component AC in the horizontal axial direction at (0, 7), data indicating the frequency value of the highest AC component AC in the vertical axial direction at (7, 0), and data representing the maximum frequency value of the AC component AC in the oblique direction at (7, 7). At the middle position, frequency data in the direction having correlation with the coordinates is stored in such a manner that data with lower frequency sequentially appear from the origin side.
Then, the data stored at each set of coordinates in this matrix is divided by the quantization width for each frequency component acquired by multiplication of the determined, quantized matrix by the quantization width coefficient .alpha., thereby performing linear quantization (see (c)). The quantized value is then subjected to the Huffman coding as entropy coding. At this time, with regard to the DC component DC of this block, the differential value between the DC component DC and that of a nearby block is expressed by a group number (number of added bits) and added bits, the group number is subjected to the Huffman coding, and the acquired coded words in combination with the added bits are taken as coding data (d1, d2, e1, e2).
Regarding the AC component AC also, coefficients valid (values being not "0") are expressed by the group number and added bits.
Accordingly, the AC component AC undergoes the so-called zigzag scanning which is to scan data from a lower frequency component to a higher one, the two-dimensional Huffman coding is executed on the basis of the number of consecutive invalid (having a value of "0"), i.e., the number of zero runs, and the group number of the value of the subsequent valid component, with obtained coded words and added bits taken as coding data.
The Huffman coding is executed in such a way that with the peak frequency of occurrence in the data distribution of each of the DC component DC and AC component AC per frame image taken as the center, coded words are acquired by coding data with such bit assignment that the closer the data to the center, the fewer the number of bits assigned thereto, and the farther the data from the center, the greater the number of bits assigned thereto.
The above is the basic portion of this system.
With this basic portion alone, the amount of codes does not become constant for each image due to the use of the Huffman coding as entropy coding. For example, the following process is performed as a method of controlling the amount of codes.
First, the processing of the basic portion is executed using a temporary quantization width coefficient .alpha., and the total amount of codes (total number of bits) generated on the entire screen is acquired at the same time (see (g)). From this total amount of codes, the target amount of codes, and the temporary quantization width coefficient .alpha., the optimal quantization width coefficient .alpha. to make the amount of codes approach the target amount of codes to the DCT coefficient will be predicted by the Newton-Raphson iteration (see (h)). Using this quantization width coefficient .alpha. (i), the process following the quantization of the aforementioned basic portion is repeated. Then, from the total amount of codes generated this time, the total amount of codes generated previously the target amount of codes, the presently used quantization width coefficient .alpha., and the previously used quantization width coefficient .alpha., the optimal quantization width coefficient .alpha. to make the amount of codes approach the target amount of codes is predicted again.
When the predicted quantization width coefficient .alpha. coincides with the previous one .alpha. and the total amount of codes presently generated is less than the target amount of codes, the process is terminated and the presently generated code data is output and stored in the memory card (see (f)). If otherwise, the quantization width coefficient .alpha. is altered and the process is repeated using this new quantization width coefficient .alpha..
As described above, according to a digital electronic still camera, for instance, the number of images recordable on a single memory card or magnetic disk drive should be secured so that the image data is compressed before storage, which therefore requires that the processing time be as short as possible and constant from the view point of the operability. These conditions are somewhat needed not only in the digital electronic still cameras, but also in other applications.
The above-described system according to the proposal of the international standardization is a compressing method which satisfies those conditions. According to this system, however, although the combination of the orthogonal transform and entropy coding for each block as discussed in the foregoing description of the basic portion can compress image data at high efficiency, the amount of codes is not constant depending on images due to the use of the entropy coding, making unstable the number of images recordable on a recording medium, such as a memory card or magnetic disk drive.
Further, according to the method of controlling the amount of codes as exemplified in the description of the prior art, how many times the pass of the basic portion of the coding should be repeated would differ depending on images, making the processing time unstable and generally requiring a longer processing time.